<?php
session_start() ;
if(!isset($_SESSION["login"]) || $_SESSION["login"] == "")
{   
  header("Location: index.php?error=4") ;
}?>

<html>
<head>
<title>Administration</title>
 <link rel="stylesheet" type="text/css" href="style.css" > 
 <script type="text/javascript" src="js/calendrier.js"></script>
</head>

<body>
<?php require("menu.php");
require("fonctions.php");
$code=$_GET["error"];
?>
<br></br>
<?php
$code=$_GET["error"]; 
echo error_message($code);?>
<table class="ds_box" cellpadding="0" cellspacing="0" id="ds_conclass" style="display: none;">
			<tr>
				<td id="ds_calclass"></td>
			</tr>
		</table>


<p class="titre">D&eacute;finir un push</p>

<table>
<tr>
	<td class="tab_dis_head">Liste des pushs</td>
</tr>
</table>
<table class="tab_vag">

<tr>
	<td class="tab_dis_head">Description</td><td class="tab_dis_head">Date de d&eacute;but</td> <td class="tab_dis_head">Date de fin</td>
	<td class="tab_dis_head">
	Statut
	</td>
	<td class="tab_dis_head">Actions</td>
</tr>

<?php $sql="select * from vagues_camp";
$res = mysql_query($sql);
while($r = mysql_fetch_object($res)){
?>

<tr>
	<td class="tab_dis_data"><?php echo $r->descrip;?></td><td class="tab_dis_data"><?php echo $r->date_deb;?></td> <td class="tab_dis_data"><?php echo $r->date_fin;?></td>
	<td class="tab_dis_data"><?php echo $r->statut;?></td>
	<td class="tab_dis_data"><a href="lv_plan.php?action=modif_push&id_push=<?php echo $r->id;?>">Modifier</a> / <a href="controler.php?action=sup_camp&id=<?php echo $r->id;?>">Supprimer</a> / 
	<a href="mail_proto.php?action=run_camp&id_push=<?php echo $r->id;?>">Lancer</a></td>
</tr>

<?php }?>
</table>
<br></br>

<?php 
$action = $_GET["action"];
$id_push = $_GET["id_push"];
if($action=="modif_push"){ 
$sql="select * from vagues_camp where id=$id_push";
$res = mysql_query($sql);
$r = mysql_fetch_object($res);
	
	?>
<form action="controler.php?action=modif_push" method="post" name="">

<table >

<tr>
<TD>Choisir une vague</TD> <TD>
	<select name="descrip">
	<?php 
	$sql1="select * from vagues";
	$res1 = mysql_query($sql1);
	
	while($r1 = mysql_fetch_object($res1)){?>
		<option value="<?php echo $r1->descrip;?>" <?php if($r->descrip==$r1->descrip) echo "selected";?>><?php echo $r1->descrip;?></option>
		
		<?php }?>
	</select>
</TD>
</tr>
<tr>
<TD id="ds_calclass">Date de d&eacute;but</TD> <TD><input type="text" name="datedeb" onclick="ds_sh(this);" value="<?php echo $r->date_deb;?>" /></TD>
</tr>
<TR>
<TD id="ds_calclass">date de fin</TD> <TD><input type="text" name="datefin" onclick="ds_sh(this);"  value="<?php echo $r->date_fin;?>"  /></TD>
</tr>
<tr>
	<td>Message</td><td><textarea cols="75" rows="25" name="message"><?php echo "$r->message";?></textarea></td>
</tr>
<tr>
<TD colspan="2" align="center"><input type="submit" name="enr" value="Modifier le push !"></TD>
</tr>


</table>




</form>


<?php }else{?>
<form action="controler.php?action=crea_push" method="post" name="crea_vag">

<table >

<tr>
<TD>Choisir une vague</TD> <TD>
	<select name="descrip">
	<?php 
	$sql="select * from vagues";
	$res = mysql_query($sql);
	
	while($r = mysql_fetch_object($res)){?>
		<option value="<?php echo $r->descrip;?>"><?php echo $r->descrip;?></option>
		
		<?php }?>
	</select>
</TD>
</tr>
<tr>
<TD id="ds_calclass">Date de d&eacute;but</TD> <TD><input type="text" name="datedeb" onclick="ds_sh(this);" /></TD>
</tr>
<TR>
<TD id="ds_calclass">date de fin</TD> <TD><input type="text" name="datefin" onclick="ds_sh(this);" /></TD>
</tr>
<tr>
	<td>Message</td><td><textarea cols="75" rows="25" name="message"></textarea></td>
</tr>
<tr>
<TD colspan="2" align="center"><input type="submit" name="enr" value="Valider un push !"></TD>
</tr>


</table>




</form>

<?php }?>

</body>

</html>
